package com.songcan.oauth.handle;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Slf4j
public class FormAuthenticationFailureHandler implements AuthenticationFailureHandler {

    @Override
    public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
        log.debug("表单登录失败:{}", e.getLocalizedMessage());
//        httpServletResponse.sendRedirect(String.format("/token/login?error=%s"
//                , HttpUtil.encodeParams(exception.getMessage(), Charset.defaultCharset())));
    }
}
